/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.manchester.biology.eqhei.persistence;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author mlwyatt
 */
@Entity
@Table(name = "AttributeSet")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AttributeSet.findAll", query = "SELECT a FROM AttributeSet a"),
    @NamedQuery(name = "AttributeSet.findByAttributeSetName", query = "SELECT a FROM AttributeSet a WHERE a.attributeSetPK.attributeSetName = :attributeSetName"),
    @NamedQuery(name = "AttributeSet.findByAttributeName", query = "SELECT a FROM AttributeSet a WHERE a.attributeSetPK.attributeName = :attributeName"),
    @NamedQuery(name = "AttributeSet.findByScoreValue", query = "SELECT a FROM AttributeSet a WHERE a.scoreValue = :scoreValue")})
public class AttributeSet implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected AttributeSetPK attributeSetPK;
    @Column(name = "scoreValue")
    private Short scoreValue;
    @OneToMany(mappedBy = "attributeSet")
    private Collection<EvaluationSection> evaluationSectionCollection;

    public AttributeSet() {
    }

    public AttributeSet(AttributeSetPK attributeSetPK) {
        this.attributeSetPK = attributeSetPK;
    }

    public AttributeSet(String attributeSetName, String attributeName) {
        this.attributeSetPK = new AttributeSetPK(attributeSetName, attributeName);
    }

    public AttributeSetPK getAttributeSetPK() {
        return attributeSetPK;
    }

    public void setAttributeSetPK(AttributeSetPK attributeSetPK) {
        this.attributeSetPK = attributeSetPK;
    }

    public Short getScoreValue() {
        return scoreValue;
    }

    public void setScoreValue(Short scoreValue) {
        this.scoreValue = scoreValue;
    }

    @XmlTransient
    public Collection<EvaluationSection> getEvaluationSectionCollection() {
        return evaluationSectionCollection;
    }

    public void setEvaluationSectionCollection(Collection<EvaluationSection> evaluationSectionCollection) {
        this.evaluationSectionCollection = evaluationSectionCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (attributeSetPK != null ? attributeSetPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AttributeSet)) {
            return false;
        }
        AttributeSet other = (AttributeSet) object;
        if ((this.attributeSetPK == null && other.attributeSetPK != null) || (this.attributeSetPK != null && !this.attributeSetPK.equals(other.attributeSetPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "edu.manchester.biology.eqhei.business.AttributeSet[ attributeSetPK=" + attributeSetPK + " ]";
    }
    
}
